package com.myfum.wingplayer.commands
{
	import com.myfum.wingplayer.entity.ScheduleLineData;
	import com.myfum.wingplayer.events.TaskEvent;
	import com.myfum.wingplayer.model.ProgramLocator;
	import com.myfum.wingplayer.utils.FileManager;
	import com.myfum.wingplayer.utils.TaskManager;
	
	import flash.filesystem.File;
	
	import org.robotlegs.mvcs.Command;
	
	public class StartUpCommand extends Command
	{
		[Inject]
		public var task:TaskManager;
		[Inject]
		public var locator:ProgramLocator;
		[Inject]
		public var fileManager:FileManager;
		
		public function StartUpCommand()
		{
			super();
		}
		
		override public function execute():void{
			var date:Date = new Date();
			var f:File = fileManager.getScheduleByDay(date.day);
			var sd:ScheduleLineData = new ScheduleLineData(f);
			sd.serialize();
			
			locator.day = sd.day;
			locator.arrayCollection = sd.arrayCollection;
			
			eventDispatcher.dispatchEvent(new TaskEvent(TaskEvent.SCHEDULE_CHANGED));
			
//			task.retrieve();
		}
	}
}